<!DOCTYPE html>
<html class="x-admin-sm">
<#include "../layout/meta.ftl">
<body class="layui-layout-body">
<div style="margin: 2vw">

    <table class="layui-table">
        <colgroup>
            <col width="150">
            <col width="200">
        </colgroup>
        <thead>
        <tr>
            <th>ID</th>
            <th>状态</th>
            <th>主节点状态</th>
            <th>节点可用性</th>
            <th>描述</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>

        <#list nodeList as node>
            <tr>
                <td>${node.id}</td>
                <td>${node.status.state}</td>
                <td><#if node.managerStatus??>${node.managerStatus}<#else>无</#if></td>
                <td>${node.spec.availability}</td>
                <td>${node.description}</td>
                <td>
                    <button onclick="change('${node.id}',1)" class="layui-btn layui-btn-normal">上线</button>
                    <button onclick="change('${node.id}',2)" class="layui-btn layui-btn-normal">暂停</button>
                    <button onclick="change('${node.id}',3)" class="layui-btn layui-btn-normal">下线</button>
                </td>
            </tr>
        </#list>

        </tbody>
    </table>

    <script>

        function change(id,type) {
            $.ajax({
                url: "/swarm/updateSwarmNode",
                data: {
                    id:id,
                    type:type
                },
                type: "post",
                success: function (res) {
                    layer.msg(res.msg);
                    setTimeout(function () {
                        location.reload();
                    }, 1000)
                }
            });
        }
    </script>

</div>
</body>
</html>